<?php
require_once( BUSINESS . 'GearDao.php');

class GearMaint_Model extends Base_Model
{
	
	public function __construct( $data )
	{
		parent::__construct( $data );
	}
	
	protected function doModel( $input)
	{
		$this->data['gear'] = $this->getGearList();
		
		$this->data['fields'] = $this->getFields( $this->data['gear']);
		//$fields = $geardao->getGearFields();
		
		//array_shift( $fields); //pop off the id field which is the first field.
		
		//$this->data['fields'] = $fields;
	}
	
	private function filter_user_input( )
	{
		
	}
	
	private function getGearList()
	{
		$geardao = new GearDao();
		$list = $geardao->getGearList();
		
		$filter_out = array('id', 'class__', 'type__' );
		
		foreach( $list as &$row)
		{
		 	foreach($filter_out as &$f)
		 	{
		 		unset($row[$f]);
		 	}
		}
		
		return $list;
	}
	
	private function getFields( $gearlist )
	{
		if (!isset($gearlist[0]))
			return array();
		$row = $gearlist[0];
		$fields = array_keys( $row);

		return $fields;
	}
	
	
	
}	//end of class